/*var stateObj={page:'myphotoalbum',}


history.pushState(stateObj, "作品", "");*/

/*window.onpopState = function(){
	var json = window.history.state;//获取当前所在的state
    if (json && json.page == "myphotoalbum") { //page即是pushState时设置的参数
        if (searchParams.sourceUrl && !selected) {
            history.go(-1);
        } else {
            document.querySelector('.product-page').removeCls('show');
            document.querySelector(".uploadcon").classList.remove("show");
        }
    }
   
    
}*/

history.pushState({page: 'myphotoalbum'}, '', '');
window.addEventListener('popstate', function(event) {	
	if(!$(".editorcon .editor_view").is(":hidden")){
		history.pushState(null, '', '');	
		
		if(!$(".editor_textview").is(":hidden")){//编辑作品
			$('.editor_textview').fadeOut()
			$(".text_contain").animate({bottom: '0'}, "slow");	
			$(".text_input").val('');
			$(".textviewInputmask").css("height",$('.editor_textview').height()-$(".text_contain").height());
			
		}
		
		if(!$(".layoutcon").is(":hidden")){
			$(".layout_change").addClass(".out_layout_change");
			$('.layoutcon').fadeOut()
			$(".layoutbox").animate({bottom: '-100%'}, "slow");
			
		}
		
		if(!$(".up_page").is(":hidden")){
			$('.up_page').fadeOut()
			$(".up_pagecontain").animate({bottom: '-100%'}, "slow");
			
		}
		document.title = "作品";
		$(".editorcon .editor_view,.editorcon ").hide();
		$(".myphotoalbum").show();
		
	}else if(!$(".editorcon .editor_oper_con").is(":hidden")){//编辑作品 
		history.pushState({page: 'myphotoalbum'}, '', '');
		document.title = "编辑作品";
		$(".editorcon .editor_view ").show();
		$(".editorcon .editor_oper_con").hide();
		
		if(!$(".up_page").is(":hidden")){
			$('.up_page').fadeOut()
			$(".up_pagecontain").animate({bottom: '-100%'}, "slow");
		}
	}else if(!$(".previewcon").is(":hidden")){//预览作品
		history.pushState(null, '', '');
		if(UtilProperty[workid].workerInfo.status==1){
			document.title = "作品";
			$(".previewcon").hide();
			$(".myphotoalbum").show();
		}else if(UtilProperty[workid].workerInfo.status==0){
			document.title = "编辑作品";
			$(".previewcon").hide();
			$(".editorcon,.editorcon .editor_view").show();
		}
		
		
	}else if(!$(".submitalbum").is(":hidden")){//提交作品
		history.pushState({page: 'myphotoalbum'}, '', '');
		document.title = "预览作品";
		$(".submitalbum").hide();
		$(".previewcon").show();
		
		
	}else if(!$(".uploadcon ").is(":hidden")){//上传作品
		history.pushState(null, '', '');
		document.title = "作品";
		$(".uploadcon").hide();
		$(".myphotoalbum").show();
		imageArray=[];
		$(".uploadoper").find("a").eq(1).removeAttr("on");
		
	}else if(!$(".myphotoalbum").is(":hidden")){//提交作品
		//WeixinJSBridge.call('closeWindow');
		
	}
	
	
	
  //console.log('location: ' + document.location);
  //console.log('state: ' + JSON.stringify(event.state));
  
  
  
});